#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007ll
#define tt int t; cin>>t; while(t--)
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define ff first
#define ss second
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define repr(i,s,e) for(int i=s;i>=e;i--)
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pii>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define pll pair<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define sz(a) int(a.size())
#define inf 1000000000000000000
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
vl factorial(ll n,ll m){ vl fact(n+1,1);for (int i = 2; i <= n; ++i){fact[i]=(fact[i-1]*i)%m;} return fact;}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}
int pow_fun(int b,int p){if(p==0) return 1;int res=1; while(p){if(p&1) res*=b;b=b*b;p=p/2;}return res;}
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 0;
cin >> t;
while (t--)
{
int n=0,m=0,a=0,b=0,c=0,d=0,sum=0,diff=0,maxN=0,minN=0,count=0,temp=0;
bool flag = false;
cin>>n;
vector<int>vv;
for(int i=0; i<n; i++){
int xx; cin>>xx;
vv.push_back(xx);
}
vector<int>ans;
if(vv[n-1]==1){
cout<<"NO"<<endl;
continue;
}
cout<<"YES"<<endl;
int cnt=0;
for(int i=n-1; i>=0; i--){
if(vv[i]==0){
for(int k=0; k<cnt-1; k++){
cout<<0<<" ";
}
if(cnt){
cout<<cnt<<" ";
}
cout<<0<<" ";
cnt=0;
}
else if(vv[i]==1){
cnt++;
}
}
if(cnt){
for(int k=0; k<cnt-1; k++){
cout<<0<<" ";
}
cout<<cnt<<endl;
}
}
return 0;
}
232. Implement Queue using Stacks | 844. Backspace String Compare |
20. Valid Parentheses | 746. Min Cost Climbing Stairs |
392. Is Subsequence | 70. Climbing Stairs |
53. Maximum Subarray | 1527A. And Then There Were K |
1689. Partitioning Into Minimum Number Of Deci-Binary Numbers | 318. Maximum Product of Word Lengths |
448. Find All Numbers Disappeared in an Array | 1155. Number of Dice Rolls With Target Sum |
415. Add Strings | 22. Generate Parentheses |
13. Roman to Integer | 2. Add Two Numbers |
515. Find Largest Value in Each Tree Row | 345. Reverse Vowels of a String |
628. Maximum Product of Three Numbers | 1526A - Mean Inequality |
1526B - I Hate 1111 | 1881. Maximum Value after Insertion |
237. Delete Node in a Linked List | 27. Remove Element |
39. Combination Sum | 378. Kth Smallest Element in a Sorted Matrix |
162. Find Peak Element | 1529A - Eshag Loves Big Arrays |
19. Remove Nth Node From End of List | 925. Long Pressed Name |